#include <iostream>
#include <vector>
#include <cassert>
#include <string>

using namespace std;

bool firstAssign(vector <int> &start, vector <int> &end, int i, int j) {
   assert(start.size()==end.size());
   assert(start.size() > 0);
   if (j-i+1 < start.size()) return false;

   start[0] = i;
   for (int a=1; a<start.size(); ++a) {
      start[a] = a+i;
   }
   end[end.size()-1] = j;
   for (int a=(int)end.size()-2; a>=0; --a) {
      if (start[a+1] < end[a+1]) {
	 end[a] = start[a+1];
      }
      else end[a] = start[a];
   }
   return true;
}

bool nextAssign(vector <int> &start, vector <int> &end, int i, int j) {
   for (int a=(int)start.size()-1; a>0; --a) {
      if (start[a] < end[a]-1) {
	 ++start[a];
	 for (int b=a+1; b<start.size(); ++b) {
	    start[b] = start[b-1]+1;
	    end[b-1] = start[b];
	 }
	 end[a-1] = start[a]; 
	 return true;
      }
   }
   return false;
}

int main() {
   vector <int> start(10);
   vector <int> end(10);

   int i=0; 
   int j=20;
   bool f = firstAssign(start,end,i,j);
   while (f) {
      for (int a=0; a<start.size(); ++a) cout<<"["<<start[a]<<","<<end[a]<<"] ";
      cout<<"\n";
      f=nextAssign(start,end,i,j);
   }

}
